#pragma warning (disable: 4819)
#include "MyToolBar.h"

#include "vtkObject.h"
#include "vtkSlicerApplication.h"
#include "vtkKWToolbarSet.h"
vtkStandardNewMacro(CustomToolBar);

CustomToolBar::CustomToolBar(void)
{
}

CustomToolBar::~CustomToolBar(void)
{
}
void CustomToolBar::ProcessGUIEvents ( vtkObject *caller, unsigned long event, void *callData )
{
	vtkSlicerApplication * app = (vtkSlicerApplication * )GetApplication();
	if (event == vtkKWPushButton::InvokedEvent)
	{
		app->GetApplicationGUI()->GetApplicationToolbar()->GetModuleChooseGUI()->SelectModule("Endoscope");
	}

}
void CustomToolBar::BuildGUI(void)
{
	vtkSlicerApplication *app = vtkSlicerApplication::SafeDownCast( GetApplication() );
	vtkSlicerWindow *win = app->GetApplicationGUI()->GetMainSlicerWindow();
	vtkKWToolbarSet *tbs = win->GetMainToolbarSet();
	vtkKWToolbar *mytb = vtkKWToolbar::New();
	mytb->SetParent ( tbs->GetToolbarsFrame ( ) );
	mytb->Create();
	mytb->SetWidgetsFlatAdditionalPadX ( 0 );
	mytb->SetWidgetsFlatAdditionalPadY ( 0 );
	mytb->ResizableOff ( );
	mytb->SetReliefToGroove ( );
	mytb->SetWidgetsPadX ( 3 );
	mytb->SetWidgetsPadY ( 2 );
	tbs->AddToolbar(mytb);
	vtkKWPushButton * b1 = vtkKWPushButton::New();
	b1->AddObserver(vtkKWPushButton::InvokedEvent, GetGUICallbackCommand());
	b1->SetParent(mytb->GetFrame());
    b1->Create();
	b1->SetReliefToFlat();
	b1->SetBalloonHelpString("Endoscope Interface");
	b1->SetImageToPredefinedIcon(vtkKWIcon::IconEye);
	mytb->AddWidget(b1);
	b1->Delete();
	mytb->Delete();
}